chai = require 'chai'
chai.should()
sinon = require 'sinon'


{Refresh} = require "../src/refresh"
{MemoryRepository} = require "../src/memoryRepository"

describe 'verify Api Key instance', ->
  it 'should return true with valid Api Key',(done) ->
    apiKeyId = '1234'
    memoryRepository = new MemoryRepository()
    apiKey = new Object()
    apiKey.Id = apiKeyId
    memoryRepository.set apiKeyId, apiKey, ()->
      refresh = new Refresh(memoryRepository)
      refresh.validateApiKey apiKeyId, (err, value)->
        value.should.be.true
        done()

  it 'should return false with invalid Api Key', (done)->
    apiKeyId = '5678'
    memoryRepository = new MemoryRepository()
    refresh = new Refresh(memoryRepository)
    refresh.validateApiKey apiKeyId, (err,value)->
      value.should.be.false
      done()
